home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1986 November & December / rerun-1986-11-12.d64 / math square-off (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  107 lines

  1. 1 clock=100:sys65517:ifpeek(781)=22then10
  2. 2 poke53280,0:poke53281,0:printchr$(142):printchr$(8):x=15:sw=40:ss=1024
  3. 9 goto 20
  4. 10 x=6:poke36879,8:sw=22
  5. 12 ss=4*(peek(36866)and128)+64*(peek(36869)and112)
  6. 20 gosub2000:dima(9),b(9),z$(12),s(6):y$="[219][192][214][206]"
  7. 30 def fnd(x)=int(rnd(1)*x)+1:print"":dc$=""
  8. 100 ss=ss+sw*5+x+1:pl=65520
  9. 105 x2$="[221] [221] [221] [221] [221] [221]"
  10. 107 x1$="[221]         [221]"
  11. 110 h$=mid$(str$(z),2):d$=mid$("[192][192][192]",1,len(h$)):print"[147] hi":print"[176]"d$"[174]"
  12. 112 print"[221]"h$"[221]"
  13. 115 print"[173]"d$"[189]":printtab(x)"[213][192][192][192][192][192][192][192][192][192][201]
  14. 120 [129]i[178]1[164]2:[153][163]x);x1$
  15. 130 [153][163]x)"(NULL) (NULL)tanright$ (NULL)tanright$ (NULL)":[153][163]x);x2$
  16. 160 [153][163]x);"(NULL) mid$tan(NULL) mid$tan(NULL) (NULL)":[130]:[153][163]x);x1$
  17. 210 [153][163]x)"mid$tantantantantantantantantan(NULL)
  18. 215 wc$="":tm=cl:fori=1to9:a(i)=i:next:gosub500
  19. 220 gosub1200:fori=1to9:b(i)=a(i):next:n=1:fori=0to4:j=sw*i*2+ss:k=8
  20. 230 ifi/2=int(i/2)thenj=j+2:k=4
  21. 240 forj=jtoj+kstep4:pokej,asc(z$(n))-128
  22. 250 n=n+1:nextj:nexti:gosub700
  23. 260 fori=9to1step-1:p=fnd(i):b(0)=b(i):b(i)=b(p):b(p)=b(0):next
  24. 300 n=1:fori=0to2:forj=0to8step4
  25. 310 pokess+i*sw*4+j,b(n)+48:n=n+1:nextj:nexti
  26. 320 c=0:restore:fori=1to6:readn1,n2,n3,n4,n5,n6,n7
  27. 330 p1=b(n1):p2$=z$(n2):p3=b(n3):gosub900
  28. 340 p2$=z$(n4):p3=b(n5):gosub900:poke781,n6:poke782,n7+x-(i>3)
  29. 345 poke783,0:sys65520
  30. 350 ifa(n1)=b(n1)anda(n3)=b(n3)anda(n5)=b(n5)thenprint"";:c=c+1
  31. 355 prints(i)"[146]";:next:ifc=6thenprint:print""tab(x-1)"  you win!!  ":goto805
  32. 360 print:print""tab(x-1)"swap         [157][157][157][157][157][157][157][157][157]";:gosub600:p1=d
  33. 370 print"with";:gosub600:p2=d:p3=b(p1):b(p1)=b(p2):b(p2)=p3:goto300
  34. 500 rem p=ss-x-1+sw*3:fori=1to9:pokep,a(i)+48:p=p+2:ifi/3=int(i/3)thenp=p+*sw-6
  35. 501 p=ss-x+sw*3+1:fori=1to9:pokep,a(i)+48:p=p+1:ifi/3=int(i/3)thenp=p+sw-3
  36. 510 next:return
  37. 600 print": [164]";
  38. 605 k=1
  39. 610 getp$:ifp$<>""then660
  40. 620 k=k+1:ifk<63then610
  41. 630 tm=tm-1:gosub700:iftm=0then800
  42. 635 iftm<=20thenwc$=""
  43. 640 goto605
  44. 660 d=1
  45. 662 ifd<19thenifp$<>mid$("123456789iopkl:,./",d,1)thend=d+1:goto662
  46. 664 ifd=19then610
  47. 666 ifd>9thend=d-9
  48. 670 print"[157][157][157]   [157][157][157]"d;:return
  49. 700 poke783,1:syspl:c1=peek(781):c2=peek(782)
  50. 710 poke783,0:poke781,0:poke782,x+5:syspl
  51. 720 print""wc$;mid$(str$(tm),2)"[146] ";dc$
  52. 730 poke781,c1:poke782,c2:poke783,0:syspl:return
  53. 800 print:print"[145]"tab(x-1)"  game over":gosub500
  54. 805 iftm>zthenz=tm
  55. 810 printtab(x-4)"another game (y/n)?"
  56. 820 geta$:ifa$=""then820
  57. 830 ifa$="y"then110
  58. 840 end
  59. 900 ifp2$="[219]"thenp1=p1+p3:return
  60. 910 ifp2$="[192]"thenp1=p1-p3:return
  61. 920 ifp2$="[214]"thenp1=p1*p3:return
  62. 930 ifp3=0thenp1=-999:return
  63. 940 p1=p1/p3:return
  64. 1000 data 1,1,2,2,3,5,11,4,6,5,7,6,9,11,7,11,8,12,9,13,11
  65. 1010 data 1,3,4,8,7,16,-1,2,4,5,9,8,16,3,3,5,6,10,9,16,7
  66. 1200 k=1:fori=0to2:p1=fnd(h+1)-1:p3=-99:gosub1500:a(i*3+1)=p1
  67. 1210 z$(k)=mid$(y$,p2,1):a(i*3+2)=p3:p1=p4:p3=-99:gosub1500
  68. 1220 z$(k+1)=mid$(y$,p2,1):a(i*3+3)=p3:k=k+5:s(i+1)=p4:next:k=3
  69. 1230 fori=1to3:p1=a(i):p3=a(i+3):gosub1500:z$(k)=mid$(y$,p2,1):p1=p4:p3=a(i+6)
  70. 1240 gosub1500:z$(k+5)=mid$(y$,p2,1):k=k+1:s(i+3)=p4:next
  71. 1500 f=0:c=0:ifp3<>-99thenf=1:goto1520
  72. 1510 iff=0thenp3=fnd(h+1)-1
  73. 1520 p2=fnd(no)
  74. 1525 onp2goto1530,1540,1550,1560
  75. 1530 p4=p1+p3:return
  76. 1540 p4=p1-p3:ifp4<0andnf=0then1580
  77. 1545 return
  78. 1550 p4=p1*p3:return
  79. 1560 ifp3=0then1580
  80. 1570 p4=p1/p3:ifp4=int(p4)thenreturn
  81. 1580 c=c+1:ifc<3then1510
  82. 1590 p2=fnd(2)*2-1:goto1525
  83. 2000 print"[147]":fori=1to42:readn:next:l=0
  84. 2010 printtab(x-1)"math scramble"
  85. 2020 readx$:ifx$="*"then2050
  86. 2025 ifx$="/"thenprint:l=0:goto2020
  87. 2030 ifl+len(x$)>=swthenprint:l=0
  88. 2040 l=l+len(x$)+1:printx$"[160]";:goto2020
  89. 2050 print:printtab(x-6)"press any key to start"
  90. 2060 getp$:ifp$=""then2060
  91. 2070 print"[147]"tab(x-3)"enter level (1-4)"
  92. 2080 print""tab(x-6)"1) [219]  2) [192]  3) [214]  4) [206]"
  93. 2090 getp$:ifp$<"1"orp$>"4"then2090
  94. 2100 no=val(p$):print""tab(x-5)"highest digit to use?"
  95. 2110 getp$:ifp$<"0"orp$>"9"then2110
  96. 2120 h=val(p$):print""tab(x-6)"negative numbers (y/n)?"
  97. 2130 getp$:ifp$<>"y"andp$<>"n"then2130
  98. 2140 nf=0:ifp$="y"thennf=1
  99. 2150 return
  100. 3000 data solve,the,problems,on,the,grid,by,moving,numbers,around.
  101. 3010 data swap,numbers,by,giving,their,grid,"positions:",/,/
  102. 3020 data"    123","     iop",/
  103. 3030 data"    456"," or  kl:",/
  104. 3040 data"    789","     ,./",/,/
  105. 3050 datatime,runs,out,in,100,seconds.,good,luck!
  106. 5000 data *
  107.